package com.jbp.controller;

import com.jbp.model.Skill;
import com.jbp.model.SkillCate;
import com.jbp.model.SkillUser;
import com.jbp.service.SkillService;
import com.jbp.utils.PageUtils;
import com.jbp.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

/**
 * 技能(Skill)表控制层
 * @author cc
 * @since 2020-11-19 17:06:55
 */
@Api(tags ="APP接口--Skill" )
@RestController
@RequestMapping("rest/skill")
public class SkillController {
    @Autowired
    private SkillService skillService;

    @ApiOperation(value="热门技能")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = Skill.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/hot")
    public R hot(){
        return R.ok(skillService.hot());
    }

    @ApiOperation(value="所有技能")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = SkillCate.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/all")
    public R all(){
        List<SkillCate> list = skillService.all();
        return R.ok(list);
    }

    @ApiOperation(value="搜索技能")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = Skill.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/search")
    public R search(@RequestParam(required = false, defaultValue = "") String name){
        List<Skill> list = skillService.search(name);
        return R.ok(list);
    }

    @ApiOperation(value="申请技能列表")
    @ApiResponses({
            @ApiResponse(code = 200,message = "成功",response = SkillCate.class),
            @ApiResponse(code = 201,message = "返回失败信息")
    })
    @GetMapping("/applyAll")
    public R applyAll(@RequestAttribute("userId") Integer userId ){
        List<SkillCate> list = skillService.applyAll(userId);
        return R.ok(list);
    }



}